
import 'package:s_mankey/model/audio_detail_model.dart';
import 'package:s_mankey/model/audio_label_model.dart';
import 'package:s_mankey/provider/view_state_model.dart';
import 'package:s_mankey/service/smonkey_repository.dart';
import 'package:s_mankey/utils/audio_playes.dart';

/// 音频详情数据
class AudioDetailVModel extends ViewStateModel {

  final vid;
  AudioDetailVModel({this.vid});

  AudioDetailModel datas;

  initData() async {
    setBusy();
    try {
      datas = await SmonkeysRepository.fetchAudioDetail(vid: vid);
      setIdle();
    } catch (e, s) {
      setError(e,s);
    }
  }
}

// 音频列表数据
class AudioListVModel extends ViewStateModel {
  var datas;
  List<AudioLabelModel> tabList;

  initData() async {
    setBusy();
    try {
      datas = await SmonkeysRepository.fetchAudioList();
      tabList = datas['label'].map<AudioLabelModel>((item) => AudioLabelModel.fromJson(item)).toList();
      setIdle();
    } catch (e, s) {
      setError(e,s);
    }
  }

  // 更新数据标签
  updataData(int index){
//    tabIndex = index;
//    print('###${tabIndex}');
    notifyListeners();
  }

}